v->arch.flags = TF_kernel_mode;
- v->arch.schedule_tail = is_idle_domain(d) ?
- continue_idle_domain : continue_nonidle_domain;
+ if ( is_idle_domain(d) )
+ {
+ v->arch.schedule_tail = continue_idle_domain;
+ v->arch.cr3 = __pa(idle_pg_table);
+ }
+ else
+ {
+ v->arch.schedule_tail = continue_nonidle_domain;
+ }
v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
v->arch.ctxt_switch_to = paravirt_ctxt_switch_to;
__pa(__per_cpu_end));
}
+static void init_idle_domain(void)
+{
+ struct domain *idle_domain;
+
+ /* Domain creation requires that scheduler structures are initialised. */
+ scheduler_init();
+
+ idle_domain = domain_create(IDLE_DOMAIN_ID);
+ if ( (idle_domain == NULL) || (alloc_vcpu(idle_domain, 0, 0) == NULL) )
+ BUG();
+
+ set_current(idle_domain->vcpu[0]);
+ idle_vcpu[0] = this_cpu(curr_vcpu) = current;
+
+ setup_idle_pagetable();
+}
+
void __init __start_xen(multiboot_info_t *mbi)
{
char __cmdline[] = "", *cmdline = __cmdline;
- struct domain *idle_domain;
unsigned long _initrd_start = 0, _initrd_len = 0;
unsigned int initrdidx = 1;
module_t *mod = (module_t *)__va(mbi->mods_addr);
cmdline_parse(cmdline);
set_current((struct vcpu *)0xfffff000); /* debug sanity */
+ idle_vcpu[0] = current;
set_processor_id(0); /* needed early, for smp_processor_id() */
smp_prepare_boot_cpu();
early_cpu_init();
- scheduler_init();
-
- idle_domain = domain_create(IDLE_DOMAIN_ID);
- if ( (idle_domain == NULL) || (alloc_vcpu(idle_domain, 0, 0) == NULL) )
- BUG();
-
- set_current(idle_domain->vcpu[0]);
- this_cpu(curr_vcpu) = idle_domain->vcpu[0];
- idle_vcpu[0] = current;
-
paging_init();
/* Unmap the first page of CPU0's stack. */
init_IRQ();
+ init_idle_domain();
+
trap_init();
timer_init();
v = alloc_idle_vcpu(cpu);
BUG_ON(v == NULL);
- v->arch.cr3 = __pa(idle_pg_table);
-
/* start_eip had better be page-aligned! */
start_eip = setup_trampoline();
printk("PAE disabled.\n");
#endif
- idle_vcpu[0]->arch.cr3 = __pa(idle_pg_table);
-
if ( cpu_has_pge )
{
/* Suitable Xen mapping can be GLOBAL. */
idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i] =
l2e_from_page(virt_to_page(ioremap_pt), __PAGE_HYPERVISOR);
}
+}
+
+void __init setup_idle_pagetable(void)
+{
+ int i;
- /* Install per-domain mappings for idle domain. */
for ( i = 0; i < PDPT_L2_ENTRIES; i++ )
idle_pg_table_l2[l2_linear_offset(PERDOMAIN_VIRT_START) + i] =
l2e_from_page(virt_to_page(idle_vcpu[0]->domain->
l2_pgentry_t *l2_ro_mpt;
struct page_info *pg;
- idle_vcpu[0]->arch.cr3 = __pa(idle_pg_table);
-
/* Create user-accessible L2 directory to map the MPT for guests. */
l3_ro_mpt = alloc_xenheap_page();
clear_page(l3_ro_mpt);
/* Set up linear page table mapping. */
idle_pg_table[l4_table_offset(LINEAR_PT_VIRT_START)] =
l4e_from_paddr(__pa(idle_pg_table), __PAGE_HYPERVISOR);
+}
+void __init setup_idle_pagetable(void)
+{
/* Install per-domain mappings for idle domain. */
idle_pg_table[l4_table_offset(PERDOMAIN_VIRT_START)] =
l4e_from_page(
{
struct vcpu *p;
struct domain *d;
- int sumw[NR_CPUS];
- s_time_t sumt[NR_CPUS];
- int cpu;
+ int sumw[NR_CPUS] = { 0 };
+ s_time_t sumt[NR_CPUS] = { 0 };
- for ( cpu = 0; cpu < NR_CPUS; cpu++ )
- {
- sumw[cpu] = 0;
- sumt[cpu] = 0;
- }
-
/* Sum across all weights. */
for_each_domain( d )
{
open_softirq(SCHEDULE_SOFTIRQ, __enter_scheduler);
- for ( i = 0; i < NR_CPUS; i++ )
+ for_each_cpu ( i )
{
spin_lock_init(&per_cpu(schedule_data, i).schedule_lock);
init_timer(&per_cpu(schedule_data, i).s_timer, s_timer_fn, NULL, i);
SET_HEAP_SIZE(&dummy_heap, 0);
SET_HEAP_LIMIT(&dummy_heap, 0);
- for ( i = 0; i < NR_CPUS; i++ )
+ for_each_cpu ( i )
{
spin_lock_init(&per_cpu(timers, i).lock);
per_cpu(timers, i).heap = &dummy_heap;
extern root_pgentry_t idle_pg_table[ROOT_PAGETABLE_ENTRIES];
extern l2_pgentry_t idle_pg_table_l2[ROOT_PAGETABLE_ENTRIES];
#endif
-extern void paging_init(void);
+void paging_init(void);
+void setup_idle_pagetable(void);
#endif
#define __pge_off() \